import {defineStore} from "pinia"

export const useMainStore  = defineStore({
  id : "main",
  state :()=>({
    name:"超级管理员"
  }),
  //类似计算属性的功能
  getters:{
    getName:(state)=> state.name,
    nameLength:(state)=> state.name.length
  },
  actions:{
    async insertName(name:string){
      // 可以做异步
      // await doAjaxRequest(data);
      // 这里使用setTimeout模拟异步
      setTimeout(()=>{
        this.name = name
      },1000)
    }
  }
})
